|
|
|
| |
|
|
|
|
Usually, it is not a good idea to attempt to override this facility with your own database errors. As long as you use the Visual Basic data control, you do not need to add database error-trapping routines to your data entry forms. The only time you need to add error-related code is when you want to perform special actions in the Error event of the data control. |
|
|
|
|
|
|
|
|
|
|
You need to add one more bit of code to complete this error trap. Add the following line of code to the Form_Activate event. |
|
|
|
|
|
|
|
|
Private Sub Form_Activate()
Data1.Refresh
End Sub |
|
|
|
|
|
|
|
|
This code makes sure the data entry fields on the form are updated with the most recent data from the database. |
|
|
|
|
|
|
|
|
Now save and run the project. You first see a message telling you that the database is missing (Figure 14.13). |
|
|
|
|
|
|
|
|
Figure 14.13.
Custom error message in
the Data1_Error event. |
|
|
|
|
|
|
|
|
Next, the open file dialog waits for you to locate and load the requested database (Figure 14.14). |
|
|
|
|
|
|
|
|
Figure 14.14.
Locating the requested database. |
|
|
|
|
|
|
|
|
Finally, once you load the database, the data entry screen comes up ready for your input. |
|
|
|
|
|